//Ryan Wachowiak, Nate Popham
//neon fragment shader

varying vec3 pos;
varying vec3 norm;
varying vec3 eye;

uniform vec3 samples[256];
uniform vec4 neon;
uniform int lastPoint;

void main()
{
	vec4 color = gl_FrontMaterial.ambient;
	vec4 neonContrib = vec4(0.0, 0.0, 0.0, 1.0);
	float brightest = 0.0;
	for(int i = 0; i < lastPoint; i++)
	{
		float contrib = dot(normalize(samples[i] - pos), norm) / (length(samples[i] - pos) * length(samples[i] - pos));
		if(contrib > brightest)
		{
			brightest = contrib;
			neonContrib = neon * dot(normalize(samples[i] - pos), norm) / (length(samples[i] - pos) * length(samples[i] - pos));
		}
		//neonContrib += neon * dot(normalize(samples[i] - pos), norm) / (length(samples[i] - pos) * length(samples[i] - pos)) / 30.0;
	}
	color += neonContrib;
	gl_FragColor = color;
}